module Proxy.Game where
import Proxy.Orders
import Proxy.TechTypes
import Proxy.UpgradeTypes

type Id = Int

type PlayerId = Id

type UnitId = Id

type Name = String

type Location = (Int, Int)

type Width = Int

type Height = Int

type Slot = Int

type Speed = Int

type Buildable = Bool

type Walkable = Bool

data Tile = Tile Height Buildable Walkable deriving Show

data Race = Zerg
          | Terran
          | Protoss
          | OtherRace
          | UnknownRace
          | SelectRace
          | RandomRace
          | NoneRace deriving (Show, Enum)

data PlayerType = NotUsed
                | Computer
                | Human
                | Rescuable
                | UnknownPlayerType0
                | ComputerSlot
                | OpenSlot
                | Neutral
                | ClosedSlot
                | UnknownPlayerType1
                | HumanDefeated
                | ComputerDefeated deriving (Show, Enum)

data PlayerInfo = PlayerInfo { playerId :: PlayerId
                             , playerRace :: Race
                             , playerName :: Name
                             , playerType :: PlayerType
                             } deriving Show

data Player = Me PlayerInfo
            | Ally PlayerInfo
            | Enemy PlayerInfo deriving Show

data Map = Map Name Width Height [[Tile]]

data Choke = Choke Location Width deriving Show

type Minerals = Int

type Gas = Int

data Resources = Resources Minerals Gas deriving Show

type Health = Int
type Shields = Int
type Energy = Int

type Time = Int

type OrderTimer = Int

type AddonId = Id

type MineCount = Int

type Used = Int

type Total = Int

data Supply = Supply Used Total deriving Show

data TechStatus = TechNotResearched
                | ResearchingTech
                | TechResearched deriving Show

instance Enum TechStatus where
    toEnum 0 = TechNotResearched
    toEnum 1 = ResearchingTech
    toEnum 4 = TechResearched
    fromEnum (TechNotResearched) = 0
    fromEnum (ResearchingTech) = 1
    fromEnum (TechResearched)  = 4

type Level = Int

data UpgradeStatus = UpgradeNotResearched
                   | ResearchingUpgrade
                   | UpgradeResearched Level deriving Show

instance Enum UpgradeStatus where
    toEnum 0 = UpgradeNotResearched
    toEnum 4 = ResearchingUpgrade
    toEnum n = UpgradeResearched n
    fromEnum (UpgradeNotResearched) = 0
    fromEnum (ResearchingUpgrade) = 4
    fromEnum (UpgradeResearched level) = level

